Skip to content

Fix Codex team-plan delivery and task readback - #9122

Merged
loopx-agent merged 2 commits into
mainfrom
codex/team-preview-codex-context-20261120
Nov 21, 2026
Merged

loopx-agent merged 2 commits into
mainfrom
codex/team-preview-codex-context-20261120

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Codex team-plan previews were discarded because the controller supplied scope to the adapter while the response parser read the underlying session. Even when confirmation created the tasks, the workspace retained its earlier task list until a manual refresh.

Forward the existing transient context to the session and reuse the workspace refresh after a completed team-plan confirmation. No new effect owner, configuration, authority or persisted state is introduced.

Validation:

  • Production Codex adapter/parser regression covers valid previews, context clearing and out-of-scope rejection. The 52 team-plan/action tests and 69 HTTP runtime/delegation tests passed for the transport fix; isolated installed-wheel qualification passed with File and SQLite.
  • The updated UI passed the Chat production build (including TypeScript), rendered recovery smoke, workspace contract checks and standard premerge. A fresh wheel built and installed into a temporary environment served the actual bundled UI and real SQLite backend: confirm once, return to Tasks, and see the new task without reload or the refresh control.
  • On the prior transport-fix wheel, 24 concurrent HTTP confirmations plus one replay all returned HTTP 200 and the same receipt; canonical state contained exactly one new Todo.
  • The earlier synthetic fixture's delivery-review 503 was traced to its missing adapter.kind; this is not a claimed product regression. Browser model output is deterministic; actual model execution, native desktop WebView and independent exact-head review remain unqualified. No merge or live upgrade is claimed.

Visual evidence (tested source content of 99799fa; temporary installed wheel, synthetic Goal and Agent, real backend; 1200px desktop and 390px narrow): the confirmation card preserves scope and consequences, and the task board shows the assigned item and recorded outcome without manual refresh. The narrow layout stacks the same board; no layout or wording change is introduced by this PR.

before-confirm after-tasks-desktop after-tasks-narrow

@loopx-agent loopx-agent changed the title Fix Codex team-plan previews lost during response parsing Fix Codex team-plan delivery and task readback Nov 20, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · Gemini · Google DeepMind · self_reported

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

已针对 PR #9122 exact head 99799fac2f926ec70e6a9844b012f5ee48012ebf 完成只读代码审查、基线对照复现、聚焦测试及 PR 实机 UI 截图核查(审查结论:APPROVE,无 P0/P1/P2 阻塞问题;遵循只读要求保持 PR OPEN,不执行合并)。

动机 / Motivation

使用 Codex 作为执行器的管家(Steward)会话及其背后的原生响应解析器,以及在 Dashboard 个人工作台确认团队分工提案(team.plan)后查看 Goal 任务看板的用户。

在合入基线 cc5392e 上,chat_runtime.py 将 team_plan_context 写入 CodexAppServerAdapter,但该适配器既无转发属性且 CodexChatAgentSession 也缺该字段,导致 native_turn_response 读取 session.team_plan_context 恒为 None 而静默丢弃所有 team_plan 提案预览;同时工作台确认 team.plan 后仅刷新动作状态未调用 onRefresh,用户需手动刷新才看得见新创建任务。修改至 99799fa 后,CodexAppServerAdapter 通过 property/setter 读写 self.session.team_plan_context 使预览顺利透传并支持清空,工作台在 team.plan 确认完成后自动执行 callbacks.onRefresh?.()。

基线对照验证显示 cc5392e 下同组输入返回 proposals=[] 且 session 缺少该字段,99799fac2f 下完整返回并投影 steward_team_plan_preview(且清空上下文或权限拒绝时正确拦截并保留正文),159 项聚焦 pytest 与前端契约单测通过,并通过 PR 附图实证桌面与窄屏确认后任务看板无需手动刷新即可呈现新建任务。

本 PR 仅修复 Codex 适配器向 Session 透传 team_plan_context 及前端确认完成后的工作台刷新触发,不修改权限裁决、提案存储、文案样式或布局结构,也不顺带修改 chat_runtime.py 在 finally 块清理上下文或 HTTP 异常 catch 读回路径刷新等既有关联防御改进。

若不修复这两处断点,基于默认 Codex 执行器的管家对话永远无法把合规的团队分工方案呈递给用户确认,而前端确认成功却不自动更新任务看板也会造成操作已丢单或需要手动刷新的误解。

改动思路 / Approach

入口与权威边界:管家对话执行团队分工规划时,chat_runtime.py 先调用 team_plan_admission_context(loopx/capabilities/manager_context/team_plan.py)生成当前 Turn 的只读范围解析器并写入 adapter.team_plan_context;模型响应由 CodexChatAgentSession.send 调用 native_turn_response 解析,仅当上下文对目标 Goal 返回已注册 Agent 列表时才放行 steward_team_plan_preview 提案。

沿用既有运行期调用约定与单向数据边界:由 CodexAppServerAdapter 作为属性代理转发至其拥有的 CodexChatAgentSession.team_plan_context,使原生响应解析器读取到真实授权上下文,前端则复用与 todo.create、goal.create 相同的 completed 后置 callbacks.onRefresh 触发点,零新增状态存储或副作用所有者。

仅覆盖 CodexAppServerAdapter 属性代理、CodexChatAgentSession 字段声明、PersonalWorkspacePage 确认完成后刷新判断及一条适配回归测试,其余适配器(Antigravity/DSH/ACP/直接 API)与后台任务持久化契约保持不变。

为什么不在调用方或前端绕过:此前仅因 AntigravityAdapter、DshChatAdapter、AcpChatAdapter 与直连 API 适配器均将 parse_agent_response 置于 self 上,故原生可读 getattr(self, "team_plan_context", None);唯有 CodexAppServerAdapter 将执行下沉至 self.session,从而令动态写入适配器实例的 team_plan_context 与读取 session 的 native_turn_response 脱节。在适配器上以 @property 转发到 CodexChatAgentSession 既与其余适配器保持调用接口统一,也无需让 chat_runtime.py 暴露底层 session 私有细节;而前端在 applied.reviewPlan?.interaction === "completed" 之后与 todo.create/goal.create 并列触发 callbacks.onRefresh?.(),使完全应用(team_plan_applied)、部分应用(team_plan_partially_applied)与幂等恢复(team_plan_commit_recovered)均可及时回显已落地任务(见 action_review_plan.ts:601-619)。

具体改动 / Changes

本 PR 共修改 4 个文件(+55/-2),未改动 RFC 协议或持久化 schema(spec_basis = no_spec:修复既有 team_plan_context 透传契约与前端确认后读回一致性)。

  1. loopx/capabilities/native_chat/codex_adapter.py(+9 / -0,生产代码):在 CodexAppServerAdapter 新增 @property def team_plan_context 与对应 setter,读写 self.session.team_plan_context。
  2. loopx/chat_agent.py(+2 / -1,生产代码):导入 Mapping 并在 CodexChatAgentSession 新增默认 None 的 team_plan_context: Mapping[str, Any] | None = field(default=None, repr=False) 字段,避免 repr 泄漏闭包/字典细节。
  3. apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-page.tsx(+1 / -1,前端工作台):在 applied.reviewPlan?.interaction === "completed" 分支(L2220)将 applied.actionKind === "team.plan" 并入 callbacks.onRefresh?.() 刷新条件。
  4. tests/test_steward_team_plan_preview.py(+43 / -0,回归测试):新增 test_codex_adapter_delivers_current_team_preview_context,覆盖预览放行、赋 None 清空不继承以及权限拒绝保留正文但剥离提案三种路径。

关键代码讲解

  • CodexAppServerAdapter.team_plan_context(loopx/capabilities/native_chat/codex_adapter.py:762-769):在控制器通过 adapter.team_plan_context = team_plan_context 注入或清零上下文时直接代理至 self.session.team_plan_context,让 start_turn 与 start_turn_with_attachments(均经 self.session.send -> native_turn_response)透明消费同一上下文。
  • CodexChatAgentSession.team_plan_context(loopx/chat_agent.py:700):以 dataclass 可选字段承接 Mapping[str, Any] | None 并设置 repr=False,配合 codex_adapter.py:1151 的 getattr(session, "team_plan_context", None) 使静态类型与运行时读写对齐。
  • native_turn_response(loopx/capabilities/native_chat/codex_adapter.py:1135-1156):在 output_schema is None 的常规管家对话解析路径读取 session.team_plan_context 并传给 parse_agent_response,决定是否保留或丢弃 steward_team_plan_preview 提案。
  • PersonalWorkspacePage 确认后刷新分支(apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-page.tsx:2203-2222):仅当 applied.reviewPlan?.interaction === "completed"(即已落库并经 projection_verified === true 校验)才于完成反馈后执行 await callbacks.onRefresh?.(),进而调用 dashboard-page.tsx:4040 全量同步 Goal 与 Todo 看板;门控、过期与失败分支在 L2203 已提前返回,不会误触刷屏。

对主干的风险 / Risks

未发现 P0/P1/P2 阻塞问题;作用域、边界对照及可顺带改进的非阻塞事项如下:

  • 调用方寿命、部分应用与边界核查:scope_fit 检查确认 chat_runtime.py:977 对每个管家 Turn 均会调用 team_plan_admission_context 并重新覆盖 adapter.team_plan_context;同一 session_id 在 session_open.py 下绑定固定 channel_id,且 external_audience 作用域变更时 prepare_turn_context(coordination.py:354-366)会重建 adapter,故生产路径不存在跨频道泄漏风险。但仍值得记录两项非阻塞 follow-up 改进:(1)chat_runtime.py:976 若改为无条件 adapter.team_plan_context = team_plan_context(并在 finally: 清空)及在 ChatRuntimeAdapter Protocol 补齐该属性定义,可在直接复用 adapter 的测试或未来多用途场景下彻底消除陈旧上下文与 mypy attr-defined;(2)personal-workspace-page.tsx:2289 针对 HTTP 超时后落入 catch 再经 actionReadback.refetch() 观察到已应用状态的兜底分支仅在 creationProgress?.goalId 时触发 onRefresh(既有 todo.create 亦如此),后续可一并覆盖。本 PR 无 opt-in 开关(default_off_isolation 与 authority_semantics 为 not_applicable),无新词表变更(semantic_alignment 为 not_applicable)。
  • 验证矩阵与反事实对照(exact head 99799fac2f926ec70e6a9844b012f5ee48012ebf):
    • 基线 vs PR 反事实对照:PASS — 在 merge-base cc5392e953 执行同一 _plan 与 CodexAppServerAdapter -> native_turn_response 探针得到 proposals=[](hasattr(session, "team_plan_context") == False),在 99799fac2f 同探针得到 1 条有效 steward_team_plan_preview(team-plan-fixture);runtime_codex_integration_probe 进一步串联真实 ChatSessionStore、team_plan_admission_context、start_turn、start_turn_with_attachments、offer_team_plan_confirmation 投影、None 清空及非管家频道拒绝全部通过。
    • 聚焦 pytest 回归(7 套件:test_steward_team_plan_preview.py、test_chat_team_plan_action.py、test_steward_team_plan_apply.py、test_team_plan_authority.py、test_chat_manager_model_adoption.py、test_private_chat_backlog_projection.py、test_chat_http_runtime_scope.py):PASS — 159 passed in 27.40s。
    • 前端契约单测与 UI 视觉核查:PASS — node --test apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-contract.test.mjs 通过(包含 conversation-returns、抽屉契约冒烟及 4 项时钟/未知态单测);通过 ego-browser 实地检视 PR #9122 在 99799fac2f 产出的 before-confirm(1200x854)、after-tasks-desktop(1200x854)与 after-tasks-narrow(390x844)三幅渲染截图(均呈现清晰的中文层级、已分配任务卡片 Advance the intake contract 与底部完成横幅,无截断或横向溢出)。隔离 worktree 缺 npm node_modules,故 tsc --noEmit/vite build 未在隔离目录复跑。
    • 静态检查与边界门禁:ruff check PASS(0 错误);mypy --follow-imports=silent 在修改的两文件共报 40 个既有关联旧诊断,PR 新增与修改行零报错;loopx check --scan-path ...(4 文件公私边界 clean)、scripts/check_rfc_bilingual.py、git diff --check、py_compile、control-plane-maintainability-ratchet-smoke.py、frontstage-rollout-projections-fixture-smoke.py 及 git merge-tree --write-tree origin/main 99799fac2f 均 PASS;canary premerge 中的 examples/semantic-vocabulary-drift-smoke.py 因隔离 worktree 缺 npm typescript 失败(已人工核对 diff 无词表改动)。远端 CI 在 wait_for_ci=false 下未依赖。

我的整体评价 / Verdict

  • Long-horizon 影响:improved — 打通默认 Codex 管家会话的团队规划预览透传链路并维持 Turn 间可清空与权限隔离边界,确认成功后再主动刷新任务工作台,防止用户误判或重复下发同一计划。
  • User-experience 影响:improved — 管家团队规划在 Codex 会话下恢复可见可确认,且在工作台确认后即时刷新看板显示新任务(无需用户额外点击刷新按钮)。(visual_review: inspected — 已通过浏览器会话读取并直接检视 PR #9122 在 exact head 99799fa 临时安装 wheel 构建下产出的 3 张工作台实拍截图(confirm 前 1200x854 桌面抽屉、confirm 后 1200x854 桌面任务看板、confirm 后 390x844 窄屏堆叠任务看板),并核对本 PR 仅在 personal-workspace-page.tsx 第 2220 行增加 team.plan 条件以复用 callbacks.onRefresh,未修改任何 JSX/CSS、文案或折叠展开控件(故 expanded_content 为 false,responsive_layout 为 true);桌面与窄屏下确认卡边界说明、反馈横幅与看板新任务条目层次清晰无溢出。;unverified_scope: 隔离复核 worktree 未安装 npm 前端构建工具(typescript/vite/playwright),未在本地重新打包或重跑 Playwright 实时点击;此外 team_plan_partially_applied 截图与 HTTP 失败 catch 读回(第 2289 行)未单独截屏验证。)。
  • 可观测语义 / 代码体积 / 词表边界:observable_semantics 为 intentional_change_validated(修复前 Codex 丢弃 steward_team_plan_preview 且确认后不刷新看板,修复后按既有契约正常投影与刷新,非管家会话、范围拒绝与非 team.plan 路径维持不变);code_volume 为 necessary(compatibility_assessment: retain,4 文件合计 +55/-2,完全复用现有机制与 repr=False);change_proportionality 为 proportionate(architecture_assessment: retain,附上述 follow_up 建议);default_off_isolation 与 authority_semantics 为 not_applicable;semantic_alignment 为 not_applicable。
  • 结论:PR #9122 定位精准、规模克制且验证充分,推荐 APPROVE;遵循只读边界保持 PR 为 OPEN,不执行合入。

English verdict: APPROVE exact head 99799fa (author-owned COMMENTED approval review); fixes the Codex adapter-to-session team_plan_context forwarding gap and adds callbacks.onRefresh?.() after completed team.plan confirmation in PersonalWorkspacePage, verified by base cc5392e vs head counterfactual probes, full CodexChatAgentSession + offer_team_plan_confirmation integration probe, 159 passed pytest tests, personal-workspace-contract.test.mjs, ruff, public boundary check, RFC bilingual check, and direct visual inspection of desktop/narrow screenshots (with isolated worktree lacking npm devDependencies noted as unverified build scope).

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, xhigh)

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

请管家拟定团队、并在工作台把可安排事项分给已注册 Agent 的所有者。 Codex 回答含有合法计划时,基线解析器没有读到主机提供的目标范围,回答中不会出现可确认计划。确认已有计划后,任务视图也可能仍显示旧列表。 新头把经过验证的计划送到原确认卡。确认一次后,真实后端写入一项任务,打开原 Goal 的任务看板即可读回,无需手动刷新。 在确定性模型应答、实际 Codex Session 解析器、本机打包 Web 和隔离 SQLite 上独立验证。真实模型、正式桌面 WebView 和线上外部来源未复验。

改动思路 / Approach

让实际解析回答的 Codex Session 使用原控制器的范围,成功确认后复用现有工作台刷新。 代码交付边界在 loopx/capabilities/native_chat/codex_adapter.py。审批、回执和任务写入仍由已有 action 服务负责,工作台从已有状态入口确认更新。

具体改动 / Changes

精确提交 99799fac2f926ec70e6a9844b012f5ee48012ebf。在主干 5e2c89662e 上整合无冲突。主干在同一适配器上有其他改动,因此分别复验精确头与整合树。 基线权限与投影约定

关键代码讲解

  • scoped-plan-delivery 已实现。控制器的原范围传到实际解析回答的 Session。合法计划进入原确认卡,未知 Goal 保留回答正文并丢弃计划。 范围解析 适配器转交 Session 解析
  • confirmed-task-readback 已实现。收到原提案的完成回执后,工作台发起既有状态读取。浏览器观察到一次确认请求,SQLite 读回一项新增任务,桌面和窄屏都可直接打开任务看板。 工作台入口

对主干的风险 / Risks

基线运行同一控制器用例,回答完成但计划数量为零。精确头 63 项通过,当前整合树 62 项和独立控制器用例也通过。未注册 Goal 的回答保留正文但无计划卡。八路同提案确认返回同一张回执,最终只有一项任务。既有失败恢复用例覆盖提交后响应丢失和后来更改保留。 确认前,原任务列表为空。确认后,Web 卡只有打开 Goal 的后续动作,未提供重复确认。未查询托管 CI。

我的整体评价 / Verdict

APPROVE。 桌面确认卡同时显示 Goal、负责人、任务和计划约束,确认后保留原分配回执。桌面与 390px 窄屏的任务看板都显示同一负责人和新增任务。 在确定性模型应答、实际 Codex Session 解析器、本机打包 Web 和隔离 SQLite 上独立验证。真实模型、正式桌面 WebView 和线上外部来源未复验。

English verdict: APPROVE at 99799fac2f926ec70e6a9844b012f5ee48012ebf. The real Codex response parser delivers a valid scoped preview, and one confirmed assignment appears in the packaged Workspace without manual refresh. A live model and the formally installed desktop remain unverified.

@loopx-agent
loopx-agent merged commit bdd58fc into main Nov 21, 2026
37 of 55 checks passed
@loopx-agent
loopx-agent deleted the codex/team-preview-codex-context-20261120 branch November 21, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant